#include "../include/c2eLib.h"
#include <stdio.h>

int main() {
    printf("=== c2eLib 模块化测试 ===\n");
    
    // 测试基础数学函数
    printf("\n1. 基础数学函数测试:\n");
    printf("Add(10, 20) = %d\n", Add(10, 20));
    printf("Subtract(30, 12) = %d\n", Subtract(30, 12));
    printf("Multiply(6, 7) = %d\n", Multiply(6, 7));
    printf("Divide(15.0, 3.0) = %.2f\n", Divide(15.0, 3.0));
    
    // 测试NcMap功能
    printf("\n2. NcMap数据类型测试:\n");
    NcMapHandle map = NcMapCreate();
    
    if (map) {
        printf("NcMap创建成功\n");
        
        // 设置不同类型的值
        printf("设置数据...\n");
        NcMapSetInt(map, "age", 25);
        double height_value = 175.5;
        NcMapSetDouble(map, "height", &height_value);  // 传递指针
        NcMapSetString(map, "name", "张三");
        NcMapSetString(map, "city", "北京");
        NcMapSetString(map, "job", "程序员");
        
        printf("NcMap大小: %d\n", NcMapSize(map));
        
        // 获取并显示值
        printf("\n获取数据:\n");
        int age;
        if (NcMapGetInt(map, "age", &age)) {
            printf("年龄: %d\n", age);
        }
        
        double height;
        if (NcMapGetDouble(map, "height", &height)) {
            printf("身高: %.1f\n", height);
        }
        
        const char* name = NcMapGetString(map, "name");
        if (name) {
            printf("姓名: %s\n", name);
        }
        
        // 测试获取所有键
        printf("\n所有键: %s\n", NcMapGetKeys(map));
        
        // 测试存在性检查
        printf("\n存在性检查:\n");
        printf("是否存在'age': %s\n", NcMapContains(map, "age") ? "是" : "否");
        printf("是否存在'salary': %s\n", NcMapContains(map, "salary") ? "是" : "否");
        
        // 测试删除
        printf("\n删除测试:\n");
        printf("删除'city': %s\n", NcMapRemove(map, "city") ? "成功" : "失败");
        printf("删除后大小: %d\n", NcMapSize(map));
        printf("删除后所有键: %s\n", NcMapGetKeys(map));
        
        // 测试清空
        printf("\n清空测试:\n");
        NcMapClear(map);
        printf("清空后大小: %d\n", NcMapSize(map));
        
        // 清理
        NcMapDestroy(map);
        printf("\nNcMap已销毁\n");
    } else {
        printf("NcMap创建失败\n");
    }
    
    printf("\n=== 所有测试完成 ===\n");
    return 0;
} 